import crypto from 'crypto'
import fs from 'fs'
import path from 'path'

const publicKey = crypto.createPublicKey(fs.readFileSync(path.resolve('src/0030_加解密/rsa/public.pem'), 'utf-8'))
const privateKey = crypto.createPrivateKey({
    key: fs.readFileSync(path.resolve('src/0030_加解密/rsa/private.pem'), 'utf-8'),
    passphrase: 'viya.top'
})

console.log(publicKey, privateKey);



const crypText = crypto.publicEncrypt(publicKey, Buffer.from('test'))
const text = crypto.privateDecrypt(privateKey, crypText).toString()

console.log('加密文本', crypText.toString('base64'));
console.log('解密文本', text);


